#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
inline bool cmp(int x,int y){return x < y;}

const int N = 1e6+9;
const int inf = 0x3f3f3f3f;
const double eps = 1e-7;
int _,n,m,h,cost[2*N],a[2*N],dis[2*N],u,v,w;
bool vis[2*N];
std::priority_queue< std::pair<int,int> > q;

int head[2*N],next[2*N],ver[2*N],edge[2*N],tot;
inline void link(int x,int y,int z){ver[++tot] = y , edge[tot] = z , next[tot] = head[x] , head[x] = tot;}

inline bool judge(int lim){
    if(lim < cost[1] || lim < cost[n]) return false;
    while(q.size()) q.pop();
    rep(i,1,n) dis[i] = inf , vis[i] = false;
    dis[1] = 0;
    q.push(mkp(0,1));
    while(q.size()){
        int now = q.top().second; q.pop();
        if(vis[now]) continue;
        vis[now] = true;
        for(int i = head[now];i;i = next[i]){
            if(dis[ ver[i] ] > dis[now] + edge[i] && cost[ ver[i] ] <= lim){
                dis[ ver[i] ] = dis[now] + edge[i];
                q.push(mkp(-edge[i],ver[i]));
            }
        }
    }
    if(vis[n] && dis[n] <= h) return true;
    else return false;
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef LOCAL //use "g++ xxx.cpp -DLOCAL"
        freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m >> h;
    rep(i,1,n) cin >> cost[i];
    rep(i,1,n) a[i] = cost[i];
    rep(i,1,m){
        cin >> u >> v >> w;
        link(u,v,w) , link(v,u,w);
    }
    std::sort(a+1,a+n+1,cmp);
    if(!judge(a[n])){
        cout << "AFK\n";
        return 0;
    }
    int l = 1 , r = n , mid , ans = inf;
    while(l <= r){
        mid = (l+r)>>1;
        if( judge( a[mid] ) ) ans = a[mid] , r = mid - 1;
        else l = mid + 1;
    }
    if(ans != inf) cout << ans << "\n";
    else cout << "AFK\n";
    return 0;
}